;;; init-org.el --- Description -*- lexical-binding: t; -*-
;;
;; Copyright (C) 2023 gotpl
;;
;; Author: gotpl <631707329@qq.com>
;; Maintainer: gotpl <631707329@qq.com>
;; Created: 2023-10-18 16:48:24
;; Modified: 2024-05-20 09:26:19
;; Package-Requires: ((emacs "24.3"))
;;
;; This file is not part of GNU Emacs.
;;
;;; Commentary:
;;
;;  Description
;;
;;; Code:

;; 放到最开头防止加载内置org
;; (use-package org
;;   :hook
;;   (org-mode . prettify-symbols-mode))


;; 代码高亮
(use-package org
  :mode ("\\.org\\'" . org-mode)
  :config
  (setq org-src-fontify-natively t)

  ;; (setq org-agenda-files (list "~/personal/org-mode/inbox.org"))
  ;; 放到custom.el中，因为快捷添加org到org-agenda-files会覆盖现在设置的

  (setq org-agenda-dir (expand-file-name "~/org/"))

  ;; define the refile targets
  (setq org-agenda-file-note (expand-file-name "notes.org" org-agenda-dir))
  (setq org-agenda-file-gtd (expand-file-name "gtd.org" org-agenda-dir))
  (setq org-agenda-file-work (expand-file-name "work.org" org-agenda-dir))
  (setq org-agenda-file-journal (expand-file-name "journal.org" org-agenda-dir))
  (setq org-default-notes-file (expand-file-name "gtd.org" org-agenda-dir))

  (setq org-agenda-files (list org-agenda-file-note org-agenda-file-gtd org-agenda-file-work org-agenda-file-journal org-agenda-file-journal))
  (setq org-capture-templates
            '(("t" "Todo" entry (file+headline org-agenda-file-gtd "Workspace")
              "* TODO [#B] %?\n- State \"TODO\"       from              %U"
              :empty-lines 1)
              ("n" "notes" entry (file+headline org-agenda-file-note "Quick notes")
              "* %?\n  %i\n %U"
              :empty-lines 1)
              ;; ("b" "Blog Ideas" entry (file+headline org-agenda-file-note "Blog Ideas")
              ;;  "* TODO [#B] %?\n  %i\n %U"
              ;;  :empty-lines 1)
              ("s" "Slipbox" entry  (file "inbox.org")
              "* %?\n")
              ("S" "Code Snippet" entry
              (file org-agenda-file-code-snippet)
              "* %?\t%^g\n#+BEGIN_SRC %^{language}\n\n#+END_SRC")
              ("w" "work" entry (file+headline org-agenda-file-work "Work")
              "* TODO [#A] %?\n  %i\n %U"
              :empty-lines 1)
              ("x" "Web Collections" entry
              (file+headline org-agenda-file-note "Web")
              "* %U %:annotation\n\n%:initial\n\n%?")
              ("p" "Protocol" entry (file+headline org-agenda-file-note "Inbox")
              "* %^{Title}\nSource: %u, %c\n #+BEGIN_QUOTE\n%i\n#+END_QUOTE\n\n\n%?")
              ("j" "Journal Entry"
              entry (file+datetree org-agenda-file-journal)
              "* %U - %^{heading}\n  %?"
              :empty-lines 1)))

  (setq org-todo-keywords
            (quote ((sequence "TODO(t!)" "STARTED(s!)" "|" "CANCELLED(c!)" "DONE(d!)")
                    )))
)

;; (use-package evil-org
;;   :hook (org-mode . evil-org-mode)
;;   :after (org evil)
;;   :config
;;   (require 'evil-org-agenda)
;;   (evil-org-agenda-set-keys))

(use-package org-contrib
  :ensure (:host github :repo "emacsmirror/org-contrib")
  :after org
  (require 'org-checklist))

(add-hook 'org-mode-hook #'(lambda ()
                              (display-line-numbers-mode -1)))
(use-package org-modern
  :hook (
         (org-mode . org-modern-mode)
         (org-agenda-finalize . org-modern-agenda))
  :config
  (setq org-modern-table nil))

;; 表格中英文对齐
(use-package valign
  :hook (org-mode . valign-mode)
  :ensure (:host github :repo "casouri/valign")
  :defer t)
  
(use-package org-tempo
  :ensure nil
  :after org)

(provide 'init-org)
;;; init-org.el ends here
